package main.java;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;

/**
 * @author Mathieu Carbou (mathieu.carbou@gmail.com)
 */
public final class TestExchanger extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setStatus(HttpServletResponse.SC_OK);
		MessageExchangerServlet exchangerServlet = ((MessageExchangerServlet) getServletContext().getAttribute(MessageExchangerServlet.class.getName()));
		if (exchangerServlet == null)
			return;
		exchangerServlet.broadcast(new Date() + ": broadcasting random message!");
	}
}